package com.copa.module.order.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.copa.annotation.Log;
import com.copa.domain.PageVo;
import com.copa.domain.ResponseDto;
import com.copa.module.goods.domain.dto.CategoryDto;
import com.copa.module.goods.domain.vo.CategoryAddVo;
import com.copa.module.order.domain.dto.OrderDetailDto;
import com.copa.module.order.domain.dto.OrderListDto;
import com.copa.module.order.domain.vo.OrderApplyVo;
import com.copa.module.order.domain.vo.OrderCancelVo;
import com.copa.module.order.domain.vo.OrderConfirmVo;
import com.copa.module.order.domain.vo.OrderListVo;
import com.copa.module.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.copa.constant.OrderStatusConstant.SHIPPED;

/**
 * @author copa
 * @createDate 2021-01-09 15:24
 * @function
 */
@RestController
@Api(tags = {"订单接口"})
public class OrderController {

    @Autowired
    private OrderService orderService;

    @ApiOperation(value = "查看订单列表")
    @PostMapping("/order/list")
    public ResponseDto<IPage<OrderListDto>> list(@RequestBody OrderListVo orderListVo) {
        return orderService.list(orderListVo);
    }

    @ApiOperation(value = "查看订单详情")
    @PostMapping("/order/detail")
    public ResponseDto<OrderDetailDto> detail(@RequestBody String orderId) {
        return orderService.detail(Long.valueOf(orderId));
    }

    @Log("确定是否付款")
    @ApiOperation("确定发货")
    @PostMapping("/order/confirmOrder")
    public ResponseDto<String> confirmOrder(@RequestBody OrderConfirmVo orderConfirmVo) {
        return orderService.confirmOrder(orderConfirmVo);
    }

    @Log("商家取消订单")
    @ApiOperation("取消订单")
    @PostMapping("/order/cancelOrder")
    public ResponseDto<String> cancelOrder(@RequestBody OrderCancelVo orderCancelVo) {
        return orderService.cancelOrder(orderCancelVo);
    }

    @Log("退款处理")
    @ApiOperation("申请订单退款处理")
    @PostMapping("/order/applyRefundOrder")
    public ResponseDto<String> applyRefundOrder(@RequestBody OrderApplyVo orderApplyVo) {
        return orderService.applyRefundOrder(orderApplyVo);
    }
}
